package com.hanggold.nx;

import com.hanggold.nx.bean.User;
import org.junit.Test;

import java.beans.*;

/**
 * @author <a href="mailto:sunmch@163.com">smc</a>
 * @date 2019-07-31 08:30
 * @since
 **/
public class NxOneDemo {

    @Test
    public void introspectorTest() throws IntrospectionException {

        /**
         * 停止parentUser类型的bean信息
         * 其实就是停止继承类及向上的全部类
         **/
//        BeanInfo beanInfo =  Introspector.getBeanInfo(User.class,ParentUser.class);

        BeanInfo beanInfo =  Introspector.getBeanInfo(User.class);

        MethodDescriptor[] methodDescriptors =  beanInfo.getMethodDescriptors();

        for (MethodDescriptor methodDescriptor : methodDescriptors){
            System.out.printf("method: %s \n",methodDescriptor.getName());
        }

        PropertyDescriptor[] propertyDescriptors =  beanInfo.getPropertyDescriptors();

        for (PropertyDescriptor propertyDescriptor : propertyDescriptors){
            System.out.printf("property:  %s \n",propertyDescriptor.getName());

//			propertyDescriptor.createPropertyEditor()
        }



//        BeanDescriptor beanDescriptor = beanInfo.getBeanDescriptor();
//
//        String beanName = beanInfo.getBeanDescriptor().getName();
//
//        System.out.printf("beanName:  %s \n",beanName);

        System.out.println("=============================================");

        BeanInfo beanInfo1 =  Introspector.getBeanInfo(User.class);

        MethodDescriptor[] methodDescriptors1 =  beanInfo1.getMethodDescriptors();

        for (MethodDescriptor methodDescriptor : methodDescriptors1){
            System.out.printf("method: %s \n",methodDescriptor.getName());
        }

        PropertyDescriptor[] propertyDescriptors1 =  beanInfo.getPropertyDescriptors();

        for (PropertyDescriptor propertyDescriptor : propertyDescriptors1){
            System.out.printf("property:  %s \n",propertyDescriptor.getName());
        }

    }


    @Test
    public void reflectTest(){





    }



}
